package com.ojoin.trade.common_core.web.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.ojoin.trade.common.exception.BusinessException;
import com.ojoin.trade.common.exception.DaoException;
import com.ojoin.trade.common.web.dao.impl.BaseDaoImpl;
import com.ojoin.trade.common_core.web.dao.TbMerchantuserExceptionorderDao;
import com.ojoin.trade.common_core.web.domain.TbMerchantuserExceptionorder;

/**
 * Created with IntelliJ IDEA.
 * User: Administrator
 * Date: 15-11-16
 * Time: 下午6:25
 * To change this template use File | Settings | File Templates.
 */
@Repository
public class TbMerchantuserExceptionorderDaoImpl extends BaseDaoImpl<TbMerchantuserExceptionorder> implements TbMerchantuserExceptionorderDao {

	@Override
	public List<TbMerchantuserExceptionorder> queryExceOrderByJoinuserID(
			int joinuserid) throws BusinessException {
		String mapMethodName = "queryExceOrderByJoinuserID";
        try { 
            List list = this.sqlSessionTemplate.selectList(getSqlName(mapMethodName), joinuserid);
            if (list != null && list.size() >0)
              return list ;
        } catch (Exception e) {
            throw new DaoException(String.format("查询九盈用户异常订单记录出错！语句：%s",
                    getSqlName(mapMethodName)), e);
        }
        return null;
	}

	@Override
	public int updateVOById(TbMerchantuserExceptionorder order)
			throws BusinessException {
		String mapMethodName = "updateVOById";
        try{
            return this.sqlSessionTemplate.update(getSqlName(mapMethodName), order);
        }catch (Exception e) {
            throw new DaoException(String.format("更新用户异常订单记录出错！语句：%s",
                    getSqlName(mapMethodName)), e);
        }
	}
	
	@Override
	public int updateVOByOrderId(TbMerchantuserExceptionorder order)
			throws BusinessException {
		String mapMethodName = "updateVOByOrderId";
        try{
            return this.sqlSessionTemplate.update(getSqlName(mapMethodName), order);
        }catch (Exception e) {
            throw new DaoException(String.format("更新用户异常订单记录出错！语句：%s",
                    getSqlName(mapMethodName)), e);
        }
	}
	
	@Override
	public TbMerchantuserExceptionorder queryExceOrderByOrderID(String orderid)
			throws BusinessException {
		String mapMethodName = "queryExceOrderByOrderID";
        try{
            return this.sqlSessionTemplate.selectOne(getSqlName(mapMethodName), orderid);
        }catch (Exception e) {
            throw new DaoException(String.format("查询订单流水号对应的异常订单记录出错！语句：%s",
                    getSqlName(mapMethodName)), e);
        }
	}


}
